#include <iostream>

using namespace std;

const int N = 100010;

int m, n;
int p[N], s[N];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%d", &p[i]);

    for(int i = 1; i <= n; i++) s[i] = s[i-1] + p[i];
    int l, r;
    while(m -- )
    {
        scanf("%d %d",&l, &r);
        cout << s[r] - s[l] << endl;
    }

    return 0;
}
